package com.zen.lon.open.remote.utils;

import com.zen.lon.open.remote.support.ApplicationContextProvider;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author ZonLen since on 2021/7/11 上午5:53
 */
public final class LogUtils {

  private static final String APPLICATION_NAME = ApplicationContextProvider
      .getProperty("spring.application.name");
  private static final Map<Class<?>, Logger> LOG_CACHE = new ConcurrentHashMap<>();

  public static void info(Class<?> logClass, String msg, Object... args) {
    msg = "TAX_CLOUD ->【" + APPLICATION_NAME + "】" + msg;
    LOG_CACHE.computeIfAbsent(logClass, LoggerFactory::getLogger).info(msg, args);
  }

  public static void debug(Class<?> logClass, String msg, Object... args) {
    msg = "TAX_CLOUD ->【" + APPLICATION_NAME + "】" + msg;
    LOG_CACHE.computeIfAbsent(logClass, LoggerFactory::getLogger).debug(msg, args);
  }

  public static void warn(Class<?> logClass, String msg, Object... args) {
    msg = "TAX_CLOUD ->【" + APPLICATION_NAME + "】" + msg;
    LOG_CACHE.computeIfAbsent(logClass, LoggerFactory::getLogger).warn(msg, args);
  }

  public static void error(Class<?> logClass, String msg, Object... args) {
    msg = "TAX_CLOUD ->【" + APPLICATION_NAME + "】" + msg;
    LOG_CACHE.computeIfAbsent(logClass, LoggerFactory::getLogger).error(msg, args);
  }

}
